﻿/**********页面加载时显示档住的层，直到页面加载完再将层隐藏     by Wasp   2007-7-17**********/
/********** 在页面的body中加入onload = "document.getElementById('ifFromLoad').style.display = 'none';document.getElementById('divFromLoad').style.display = 'none';"**********/

var ifFromLoad = "ifFromLoad";
var divFromLoad = "divFromLoad";
var strIFLoad = "ifLoad";  
var strDivLoad = "divRefresh";

//added by linsendu
var bversion=window.navigator.userAgent.substr(window.navigator.userAgent.indexOf("MSIE")+5,2);
bversion=parseInt(bversion)>0?parseInt(bversion):0;

function onFromLoad()
{            
            var str="<iframe id=\"" + ifFromLoad + "\" frameborder=\"0\" style=\"position: absolute;display:none; border: 1px solid #ccc; background-color: #fff; z-index: 9998;\"></iframe>";
            if (typeof(strLoadingDiv) != "undefined")
            {  
               str += "<div id=\"" + divFromLoad + "\" style=\"position:absolute;display:none;background-repeat:no-repeat;z-index: 9999;\">"+strLoadingDiv+"</div>";
            }   
            else
            {
               str += "<div id=\"" + divFromLoad + "\" style=\"position: absolute;display:none; background-color: #fff; background-image:url("+ImagePath+"onloading_bg.gif);background-repeat:no-repeat;width: 203px; height: 39px; z-index: 9999;font-size:9pt; vertical-align:middle;line-height:39px;text-align:left;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"height:39px; vertical-align:middle;\"><tr style=\"padding-top:3px;\"><td style=\"width:27px;\">&nbsp;</td><td style=\"vertical-align:middle; background:url("+ImagePath+"/onloading2.gif) no-repeat; background-position:left;width:16px;\" title=\""+ strLoad +"\" />&nbsp;</td><td><span class=\"red_num\">&nbsp;&nbsp;" + strLoad + "</span>&nbsp;&nbsp;<a href=\"#\" onclick=\"location.reload();\" style='text-decoration:underline;cursor:pointer;'>"+ Refresh +"</a></td></tr></table></div>";
            }            
            document.write(str);
            document.getElementById(ifFromLoad).style.width = window.screen.availWidth + "px";
            document.getElementById(ifFromLoad).style.height = window.screen.availHeight + 500 + "px";
            document.getElementById(ifFromLoad).style.filter = "alpha(opacity=50)";
            document.getElementById(ifFromLoad).style.opacity = 50/100;
            document.getElementById(ifFromLoad).style.MozOpacity = 50/100;  
            //document.getElementById(divFromLoad).style.left = ((window.screen.width/2)-50) + "px";
            //document.getElementById(divFromLoad).style.top = ((window.screen.height/2)-100) + "px";
            //setDivPositionCenter(document.getElementById(divFromLoad));//modify by linsendu 20110303 for 使loading层一直居中
}
onFromLoad();

function LoadShow()
{
    LoadShowByID(strIFLoad,strDivLoad);
}

function LoadShowByID(vIFLoad,vDivLoad)
{
    var objIFLoad = document.getElementById(vIFLoad);    
    var objDivLoad = document.getElementById(vDivLoad);
    if (objIFLoad && objDivLoad)
    {        
        var oS = objIFLoad.style;
	    oS.top = oS.left = oS.margin = oS.padding = "0px";
	    var wh;
	    var hg;
	    if(document.body.clientHeight<document.documentElement.offsetHeight)
	    {
		     hg = document.documentElement.offsetHeight + "px";
	    }
	    else
	    {
		    hg = document.body.clientHeight + "px";
	    }
	    if(parseInt(hg)<parseInt(document.body.scrollHeight))
	    {
	        hg=document.body.scrollHeight+"px";
	    }
	    if(parseInt(hg)<parseInt(window.screen.availHeight))
	    {
	        hg=window.screen.availHeight+"px";
	    }
	    if(document.body.clientWidth<document.documentElement.offsetWidth)
	    {
		     wh = document.documentElement.offsetWidth + "px";
	    }
	    else
	    {
		    wh = document.body.clientWidth + "px";
	    } 
	    oS.width = wh;
	    oS.height = hg;
	    oS.position = "absolute";
	    oS.zIndex = "9998";
	    oS.background = "#D3D3D3";
	    oS.filter = "alpha(opacity=50)";
	    oS.opacity = 50/100;
	    oS.MozOpacity = 50/100;  	     
	    
	    setDivPositionCenter(objDivLoad);
	}    
}
//set objDivLoad width and height,make objDivLoad center, added by linsendu
/**/
function InitScriptManager()
{
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequest);
    //prm.add_endRequest(EndRequest);
    function BeginRequest(sender, args) {    
        //document.getElementById('upsload').style.display = 'block';    
        //setDivPositionCenter(document.getElementById(strDivLoad));  
        LoadShow();
    }
//    function EndRequest(sender, args) {             
//        document.getElementById('upsload').style.display = 'none';           
//    }
}

function setDivPositionCenter(objDiv)
{   
    var ch=document.documentElement.clientHeight;    
    var sh=document.documentElement.scrollTop;
    var sl=document.documentElement.scrollLeft;
    var loadOs=objDiv.style;
    loadOs.position="absolute";
    loadOs.zIndex="9999";
    loadOs.width='203px';
    loadOs.height='39px';    
    loadOs.marginTop='0px';
    if(bversion>0&&bversion<=6){
        loadOs.left='50%';
        if(ch==0&&sh==0)
        {
            loadOs.top='50%'; 
        }
        else
        {
            loadOs.top=(parseInt(ch)/2+sh)+'px';
        }
        loadOs.marginTop='-25px';
        loadOs.marginLeft='-100px'  
    }else{ 
        loadOs.left='50%';
        loadOs.top='50%'; 
        ch=document.body.scrollTop;
        loadOs.marginTop=-(25)+sh+(parseInt(ch))+'px';
        loadOs.marginLeft=-(100)+sl+'px'; 
    } 
}
//在层不在updateProgress中时使用
function showMaskDiv()
{   
    var frameLoad=document.getElementById(strIFLoad);
    var divLoad=document.getElementById(strDivLoad);  

    frameLoad.style.display = 'block';
    divLoad.style.display = 'block'; 
    //alert('in');
    setDivPositionCenter(divLoad);
}
//在异步Ajax中时使用
function AjaxLoadShow()
{
    LoadShowByID(ifFromLoad,divFromLoad);
}
//在异步Ajax中时使用
function AjaxShowLoadMask()
{   
    var iframeLoad=document.getElementById(ifFromLoad);
    var idivLoad=document.getElementById(divFromLoad);  

    iframeLoad.style.display = 'block';
    idivLoad.style.display = 'block'; 
    //alert('in');
    setDivPositionCenter(idivLoad);
}
//隐藏加载层
function hideLoadDiv()
{
   document.getElementById(ifFromLoad).style.display = 'none';
   document.getElementById(divFromLoad).style.display = 'none';; 
}

//在层不在updateProgress中时使用
function hideMaskDiv()
{
    document.getElementById(strIFLoad).style.display = 'none';
    document.getElementById(strDivLoad).style.display = 'none'; 
}